<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>朱元璋经典语录 - 可下载卡片版</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: "Microsoft YaHei", "SimSun", sans-serif;
        }
        
        body {
            background-color: #f5f5f5;
            color: #333;
            padding: 20px;
            background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" opacity="0.05"><path d="M0,0 L100,100 M100,0 L0,100" stroke="%23999" stroke-width="1"/></svg>');
        }
        
        header {
            text-align: center;
            margin-bottom: 40px;
            padding: 20px 0;
            position: relative;
        }
        
        h1 {
            font-size: 2.5rem;
            color: #8B0000;
            text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
            margin-bottom: 10px;
        }
        
        .subtitle {
            font-size: 1.2rem;
            color: #666;
            margin-top: 5px;
        }
        
        .container {
            max-width: 1200px;
            margin: 0 auto;
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
            gap: 30px;
        }
        
        .card {
            background-color: #fff;
            border-radius: 8px;
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
            overflow: hidden;
            transition: transform 0.3s ease, box-shadow 0.3s ease;
            position: relative;
        }
        
        .card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
        }
        
        .card-header {
            background-color: #8B0000;
            color: #fff;
            padding: 15px 20px;
            font-size: 1.3rem;
            font-weight: bold;
            text-align: center;
        }
        
        .card-body {
            padding: 25px;
        }
        
        .quote {
            font-size: 1.1rem;
            line-height: 1.6;
            margin-bottom: 15px;
            font-style: italic;
        }
        
        .context {
            font-size: 0.9rem;
            color: #666;
            border-left: 3px solid #8B0000;
            padding-left: 15px;
        }
        
        .download-btn {
            position: absolute;
            bottom: 10px;
            right: 10px;
            background-color: #8B0000;
            color: white;
            border: none;
            padding: 5px 10px;
            border-radius: 4px;
            cursor: pointer;
            font-size: 0.8rem;
            opacity: 0.8;
            transition: opacity 0.3s;
        }
        
        .download-btn:hover {
            opacity: 1;
        }
        
        footer {
            text-align: center;
            margin-top: 50px;
            padding: 20px 0;
            color: #666;
            font-size: 0.9rem;
        }
        
        @media (max-width: 768px) {
            .container {
                grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
            }
            
            h1 {
                font-size: 2rem;
            }
        }
        
        @media (max-width: 480px) {
            .container {
                grid-template-columns: 1fr;
            }
            
            h1 {
                font-size: 1.8rem;
            }
        }
    </style>
    <!-- 引入html2canvas库用于将HTML元素转换为图片 -->
</head>
<body>
    <header>
        <h1>朱元璋经典语录</h1>
        <p class="subtitle">从乞丐到皇帝的霸气名言</p>
    </header>
    
    <div class="container">
        <!-- 卡片1 -->
        <div class="card" id="card1">
            <div class="card-header">草根逆袭</div>
            <div class="card-body">
                <p class="quote">"老子本来就是泥腿子，怕什么？"</p>
                <p class="context">朱元璋出身贫农，当过和尚、乞丐，造反时毫无心理负担。这句话体现了他"光脚的不怕穿鞋的"草根霸气。</p>
            </div>
            <button class="download-btn" onclick="downloadCard('card1', '朱元璋-草根逆袭')">下载卡片</button>
        </div>
        
        <!-- 卡片2 -->
        <div class="card" id="card2">
            <div class="card-header">帝王权术</div>
            <div class="card-body">
                <p class="quote">"要么不做，要么做绝！"</p>
                <p class="context">朱元璋打仗、治国、杀人都极其果断，比如胡惟庸案、蓝玉案牵连数万人，功臣几乎被杀光。</p>
            </div>
            <button class="download-btn" onclick="downloadCard('card2', '朱元璋-帝王权术')">下载卡片</button>
        </div>
        
        <!-- 卡片3 -->
        <div class="card" id="card3">
            <div class="card-header">治国铁腕</div>
            <div class="card-body">
                <p class="quote">"贪官污吏，剥皮实草！"</p>
                <p class="context">真实历史政策，贪污60两银子以上就处死，尸体剥皮塞草做成"标本"警示后人。</p>
            </div>
            <button class="download-btn" onclick="downloadCard('card3', '朱元璋-治国铁腕')">下载卡片</button>
        </div>
        
        <!-- 卡片4 -->
        <div class="card" id="card4">
            <div class="card-header">对功臣的狠</div>
            <div class="card-body">
                <p class="quote">"我的儿子们必须封王，你们的功劳再大也得死！"</p>
                <p class="context">朱元璋怕功臣威胁朱家江山，杀蓝玉、胡惟庸，却大封儿子为藩王。</p>
            </div>
            <button class="download-btn" onclick="downloadCard('card4', '朱元璋-对功臣的狠')">下载卡片</button>
        </div>
        
        <!-- 卡片5 -->
        <div class="card" id="card5">
            <div class="card-header">经典战略</div>
            <div class="card-body">
                <p class="quote">"高筑墙，广积粮，缓称王。"</p>
                <p class="context">朱升提出的战略，朱元璋完美执行，躲过了元朝和其他起义军的围剿，最终一统天下。</p>
            </div>
            <button class="download-btn" onclick="downloadCard('card5', '朱元璋-经典战略')">下载卡片</button>
        </div>
    </div>
    
    <footer>
        <p>© 2023 朱元璋经典语录 | 历史内容仅供参考</p>
    </footer>
    
    <script>
        // 下载卡片为图片的函数
        function downloadCard(cardId, fileName) {
            // 获取要转换为图片的卡片元素
            const cardElement = document.getElementById(cardId);
            
            // 使用html2canvas将卡片转换为canvas
            html2canvas(cardElement, {
                scale: 2, // 提高分辨率
                backgroundColor: null, // 透明背景
                logging: false, // 关闭日志
                useCORS: true // 允许跨域图片
            }).then(canvas => {
                // 将canvas转换为图片URL
                const imgData = canvas.toDataURL('image/png');
                
                // 创建一个a标签用于下载
                const a = document.createElement('a');
                a.href = imgData;
                a.download = fileName + '.png'; // 设置下载文件名
                document.body.appendChild(a);
                a.click(); // 模拟点击下载
                document.body.removeChild(a); // 移除a标签
            });
        }
    </script>
</body>
</html>